package appx.craft.droid.ui;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;
import appx.craft.droid.R;
import appx.craft.droid.utils.Const;
import appx.craft.droid.utils.Log;

public class VideoPreview extends FragmentActivity {
	
	public final String TAG = VideoPreview.class.getCanonicalName();
	VideoView videoView_preview;
	MediaController mMediaController;
	String strFileName;
	Button btn_close_window;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.debug(TAG,"[ onCreate ] ");
		
		strFileName = getIntent().getExtras().getString(Const.INTENT_FILE_VIDEO);
		
		setContentView(R.layout.activity_video_view);
		videoView_preview = (VideoView)findViewById(R.id.videoView_preview);
		
		mMediaController = new MediaController(VideoPreview.this);
		videoView_preview.setMediaController(mMediaController);
		videoView_preview.setVideoPath(strFileName);
		
		if(strFileName != null){
			videoView_preview.start();
		}
		
		btn_close_window = (Button)findViewById(R.id.btn_close_window);
		btn_close_window.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}
	@Override
	protected void onStart() {
		super.onStart();
		Log.debug(TAG,"[ onStart ] ");
	}
	@Override
	protected void onStop() {
		super.onStop();
		Log.debug(TAG,"[ onStop ] ");
	}
	@Override
	protected void onPause() {
		super.onPause();
		Log.debug(TAG,"[ onPause ] ");
	}
	@Override
	protected void onResume() {
		super.onResume();
		Log.debug(TAG,"[ onResume ] ");
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		Log.debug(TAG,"[ onDestroy ] ");
	}
}
